<template>
	<view class="enterprise_info_layout">
		<uni-list v-if="enterprise">
			<uni-list-item title="企业名称:" :right-text="enterprise.name"></uni-list-item>
			<uni-list-item title="企业logo:">
				<template #footer>
					<view class="enterprise_info_logo" v-if="enterprise.logo"
						:style="{height: (enterprise.logo.length ? '180rpx' : '0rpx')}">
						<image :src="enterprise.logo[0]?.url"></image>
					</view>
				</template>
			</uni-list-item>
			<uni-list-item title="法定代表人:" :right-text="enterprise.corporate_legal_person"></uni-list-item>
			<uni-list-item title="联系人:" :right-text="enterprise.contacts"></uni-list-item>
			<uni-list-item title="电话:" :right-text="enterprise.telephone"></uni-list-item>
			<uni-list-item title="注册地址:" :right-text="enterprise.address"></uni-list-item>
			<uni-list-item title="经营状态:" :right-text="enterprise_text_value(enterprise.status)"></uni-list-item>
		</uni-list>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app'

	import {
		store,
	} from '@/uni_modules/uni-id-pages/common/store.js'

	import {
		ref
	} from 'vue'

	import {
		enterprise_text_value
	} from '@/utils/enterprise.js'

	const enterprise_obj = uniCloud.importObject('opendb-enterprise')
	const enterprise = ref(null)

	onLoad(async (params) => {
		let res = await enterprise_obj.opendb_enterprise_detail(params.id)
		console.log('企业信息', res);
		if (res.errCode == 0) {
			enterprise.value = res.data
		}
	})
</script>

<style lang="scss" scoped>
	.enterprise_info_layout {

		/// 覆盖uni-list-item的属性
		::v-deep .uni-list-item__content {
			flex: none;
		}

		::v-deep .uni-list-item__extra {
			flex: 1;
			margin-left: 10rpx;
		}

		.enterprise_info_logo {
			width: 180rpx;

			image {
				height: 100%;
				width: 100%;
			}
		}
	}
</style>